# -g 开启gdb的debug调试（生成的二进制文件中包含调试信息）
# -O0 禁用优化（确保调试一致性）
# -Wall 显示所有警告
CFLAGS := -g -O0 -Wall

log := ./thirdparty/log/log.h ./thirdparty/log/log.c

log_test: ./test/log_test.c $(log)
	-gcc $^ -o $@ -I thirdparty
	-./$@
	-rm $@


cjson := ./thirdparty/cJson/cJSON.h ./thirdparty/cJson/cJSON.c $(log)

cjson_test: ./test/cJSON_test.c $(cjson)
	-gcc $(CFLAGS) $^ -o $@ -I thirdparty
#	-./$@
#	-rm $@

app_common := app/app_common.h app/app_common.c
app_common: test/time_test.c $(app_common) $(log)
	-gcc $^ -o $@ -I thirdparty -I app
	-./$@
	-rm $@

app_message := ./app/app_message.c ./app/app_message.h
app_message_test: test/app_message_test.c $(app_message) $(app_common) $(log) $(cjson)
	-gcc $^ -o $@ -I thirdparty -I app
	-./$@
	-rm $@

mqtt_test: test/mqtt_test.c
	-gcc $^ -o $@ -lpaho-mqtt3c
	-./$@
	-rm $@

app_mqtt := app/app_mqtt.h app/app_mqtt.c
app_mqtt_test: test/app_mqtt_test.c $(app_mqtt) $(log)
	-gcc $^ -o $@ -I thirdparty -I app -lpaho-mqtt3c
	-./$@
	-rm $@

app_pool:=app/app_pool.h app/app_pool.c
app_pool_test: test/app_pool_test.c $(log) $(app_pool)
	-gcc $^ -o $@  -I thirdparty -I app
	-./$@
	-rm ./$@

app_buffer := app/app_buffer.h app/app_buffer.c
app_buffer_test: test/app_buffer_test.c $(app_buffer) $(log)
	-gcc $^ -o $@ -I thirdparty -I app
	-./$@
	-rm $@
